From 7d3c428599b3b004848924b1b0a22d55b57500b8 Mon Sep 17 00:00:00 2001 From: Ian Baker Date: Tue, 13 Sep 2011 00:53:30 +0000 Subject: [PATCH] If the scaler URL is protocol-relative, things just break here. Sets a sane default. --- includes/specials/SpecialUploadStash.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/specials/SpecialUploadStash.php b/includes/specials/SpecialUploadStash.php index 3be2e816bd..ba818efea0 100644 --- a/includes/specials/SpecialUploadStash.php +++ b/includes/specials/SpecialUploadStash.php @@ -210,12 +210,20 @@ class SpecialUploadStash extends UnlistedSpecialPage { // this global probably looks something like 'http://upload.wikimedia.org/wikipedia/test/thumb/temp' // do not use trailing slash global $wgUploadStashScalerBaseUrl; + $scalerBaseUrl = $wgUploadStashScalerBaseUrl; + + if( preg_match( '/^\/\//', $scalerBaseUrl ) ) { + // this is apparently a protocol-relative URL, which makes no sense in this context, + // since this is used for communication that's internal to the application. + // default to http. + $scalerBaseUrl = 'http:' . $scalerBaseUrl; + } // We need to use generateThumbName() instead of thumbName(), because // the suffix needs to match the file name for the remote thumbnailer // to work $scalerThumbName = $file->generateThumbName( $file->getName(), $params ); - $scalerThumbUrl = $wgUploadStashScalerBaseUrl . '/' . $file->getUrlRel() . + $scalerThumbUrl = $scalerBaseUrl . '/' . $file->getUrlRel() . '/' . rawurlencode( $scalerThumbName ); // make a curl call to the scaler to create a thumbnail -- 2.20.1